<template>
  <div class="Navtable">
    <van-tabbar v-model="active" fixed placeholder safe-area-inset-bottom>
      <van-tabbar-item icon="home-o" to="/">首页</van-tabbar-item>
      <van-tabbar-item icon="add-o" to="/publish">发布</van-tabbar-item>
      <van-tabbar-item icon="manager-o" @click="add">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>

import { Tabbar, TabbarItem } from "vant";
export default {
  name: "Nav-Table",
  components: {
    [Tabbar.name]: Tabbar,
    [TabbarItem.name]: TabbarItem,
  },
  // props:{
  //   active:{
  //     default:0
  //   }
  // },
  data() {//
    return {
      active: 0,
    };
  },

  mounted() {
    // console.log(this.$route);
    if (this.$route.path === "/my") {
      this.active = 2;
    }
    if (this.$route.path === "/publish") {
      this.active = 1;
    }
    if (this.$route.path === "/home") {
      this.active = 0;
    }
  },

  methods: {
    add(){
      let token=localStorage.getItem("xl-token")
      // console.log(token)
      if(token==null){
        this.$router.push("/login")
      }else{
        this.$router.push("/my")
      }
    }
  },
};
</script>

<style lang="scss" scoped>
</style>